﻿@model Umbraco.Cms.Web.Model.BackOffice.Editors.FileEditorModel
@{
    Layout = "../Shared/_FileContentEditorLayout.cshtml";
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
    ViewBag.Action = "Save";
    ViewBag.ControllerId = new Guid(CorePluginConstants.ScriptEditorControllerId);
    ViewBag.TabTitle = "Script Editor";

    Html
        .RequiresJs("CodeMirror/codemirror.js", "Modules", 100)
        .RequiresJs("CodeMirror/mode/javascript/javascript.js", "Modules", 101)
        .RequiresJs("Umbraco.Editors/ScriptEditor.js", "Scripts", 102);
    Html
        .RequiresCss("CodeMirror/codemirror.css", "Modules", 100)
        .RequiresCss("CodeMirror/theme/umbraco.css", "Modules", 101)
        .RequiresCss("CodeMirror/mode/javascript/javascript.css", "Modules", 102);
}
@section Head {
    <script type="text/javascript">

        var editor = undefined; // Store a reference to the editor globally so that we can access from dialog windows

        (function ($) {
            $(document).ready(function () {
                editor = Umbraco.Editors.ScriptEditor.getInstance();
                editor.init({
                    editorTextBoxId: "@Html.IdFor(x => Model.FileContent)",
                    name: "@Model.Name",
                    id: "@Model.Id",
                    parentId: "@Model.ParentId",
                    codeMirrorOpts: {                        
                        matchBrackets: true
                    }
                });
            });
        })(jQuery);
    </script>
}